﻿using DevExpress.Mvvm;
using PlaceOrder_Client.ViewModels;
using Prism.DryIoc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PlaceOrder_Client.Views
{
    /// <summary>
    /// ChatMessageWindow.xaml 的交互逻辑
    /// </summary>
    public partial class ChatMessageWindow : Window
    {
        public ChatMessageWindow()
        {
            InitializeComponent();

            Messenger.Default.Register<string>(this, "ActivateChatMessageWindow", HandleActivateChatMessageWindow);
        }

        private void HandleActivateChatMessageWindow(string obj)
        {
            PrismApplication.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                // 检查窗口状态
                if (this.WindowState == WindowState.Minimized)
                {
                    // 如果窗口被最小化，恢复窗口状态
                    this.WindowState = WindowState.Normal;
                }
                //this.Activate();
                //this.Topmost = true;
            }));
     
        }

        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);
            MainViewModel._chatMessageView = null;
        }
    }
}
